package com.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import dao.UserInformationDAO;
import modle.UserInformation;
import dao.UserInformationDaoJdbcImpl;

/**
 * Servlet implementation class RankingListServlet
 */
@WebServlet("/RankingListServlet")
/**
 * 获取数据库的排行榜信息传递给前端
 * @author WXE
 *
 */
public class RankingListServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public RankingListServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
    @Override 
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		UserInformationDAO uid = new UserInformationDaoJdbcImpl();
		List<UserInformation> allUserInformation = uid.readAllUserInformation();
		request.setAttribute("list", allUserInformation);
		
		request.getRequestDispatcher("RankingList.jsp").forward(request, response);
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
    @Override 
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
